

public class QuickSort extends Sort {
	
	public QuickSort(){
		super();
	}
	
	public <T extends Comparable<? super T >> T[] sort(T[] arr){
		sort(arr, 0, arr.length-1);
		return arr;
	}

	public <T extends Comparable<? super T >> void sort(T[] arr, int start, int end){
		if (start < end) { 
			T pivot = arr[((start+end)/2)]; 
			int i = start; 
			int j = end; 
			while (i != j) { 
				if (arr[i].compareTo(pivot) < 0){ 
					i = i + 1; 
				} 
				else { 
					arr[j] = arr[i]; 
					arr[i] = arr[j-1]; 
					j = j - 1; 
				} 
			} 
			arr[j] = pivot; 
			sort(arr, start, j-1); 
			sort(arr, j+1, end); 
		} 
	}
	
}
